feat: add attestion verification negative tests - #474
Open
Stanley-Owoh wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Security: Attestation verification negative suite (Issue #399)
Expands the optional ed25519 oracle-attestation (Issue #263) test coverage with a full
negative suite, restores missing
ContractErrorvariants that prevented the contractlibrary from compiling, and documents the attestation threat model.
What changed
contracts/src/tests/attestation.rs#[should_panic]tests (wrong-key and tampered-price) intostructured
try_resolve_roundassertions that check the rejection is a fail-closedhost trap (
Err(Err(_))) and that the round remains active for a legitimate oracleto settle later —
#[should_panic]only proves the call aborts, not that state isuntouched.
window check),
attacker-supplied garbage signature field is ignored and settlement proceeds exactly
as pre-Oracle rebuild: domain-separated signed attestations #263 (account auth only).
still rejected with
OracleNonceReusedeven with a perfectly valid attestation; afresh nonce with the same key still settles (proving the guard is nonce-specific).
confidenceafter signing does not invalidatethe attestation (it is deliberately excluded from the signed message).
_build_attestation_message: fixed prefix(
XELMA_ORACLE_ATTESTATION_V1), deterministic bytes, and each bound field(network_id, contract_addr, round_id, price, timestamp, nonce) changes the message
while
confidence/attestationdo not.contracts/src/errors.rsContractErrorvariants that were referenced by the code but missing fromthe enum, which made the library fail to compile:
OracleHeartbeatUnhealthy(89),AccessDenied(90),DisputeWindowExpired(91),ClaimLocked(92).cargo build --package xelma-contractnow succeeds.SECURITY_REVIEW.mdmessage binding (network/contract/round/price/time/nonce),
confidenceexcluded,signature vouches for binding not price correctness (single-oracle trust still
applies, see SR-2026-04-004), and disabled-by-default behaviour.
ContractErrorvariant count to 29.docs/ORACLE_OPERATOR_RUNBOOK.mdattestationandconfidencefields to the OraclePayload referenceplus a concise attestation threat-note block for operators.
Verification
cargo build --package xelma-contractpasses (36 pre-existing warnings only).as a host error (
Err(Err(_))), contract errors surface asErr(Ok(_)), and successas
Ok(Ok(_))— the new assertions match real runtime behaviour.cargo test --package xelma-contract --no-run: zero errors referenceattestation.rs; the remaining errors are pre-existing drift in unrelated test modules(leaderboard, security, goldens, precision, etc.).
Pre-existing blocker (not introduced by this PR)
The contract test suite cannot currently be executed: enabling
soroban-sdk/testutilsbreaks the pre-existing
#[contracttype]derive onMarketSnapshot(
Option<RoundPhase>/Option<RoundPoolStats>,contracts/src/types.rs:492), whichblocks
cargo testfor every module. Recommend a follow-up issue to pin thesoroban-sdkmacro stack consistently.Closes #399